﻿// =================================================================== 
// 业务逻辑层(GDIT.BLL)
//====================================================================
// 文件：BCounter.cs
// 项目名称：学院网站
// 创建时间：2012-08-12
// 负责人：ChenZhiGang
//引用DevExpress.Data.Filtering，DevExpress.Xpo程序集
// 程序集介绍：网站记录率信息操作逻辑
// ===================================================================
using DevExpress.Xpo;
using DevExpress.Data.Filtering;
using GDIT.Base.LogHelper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GDIT.BLL
{
    public class BCounter
    {
        private Pattern.DALAbstractFactory dataFactory = DataProvider.defaultProvider;

        /// <summary>
        /// 增加网站被访问的记录数
        /// </summary>
        public int AddCounter(string ip)
        {
            if (System.Web.HttpContext.Current.Request.Cookies["IPAddress"] == null)
            {
                int result = dataFactory.DALCounterProvider.AddCounter();
                if (result == 1)
                {
                    System.Web.HttpContext.Current.Response.SetCookie(new System.Web.HttpCookie("IPAddress", ip));
                    return 1;
                }
                return 0;
            }
            return 0;
        }

        /// <summary>
        /// 查询网站被访问的记录数
        /// </summary>
        /// <returns>网站被访问的记录数</returns>
        public int SelectCounter()
        {
            return dataFactory.DALCounterProvider.SelectCounter();
        }
    }
}
